package edu.suda.xsap.controller;


import edu.suda.xsap.dto.EmployeeDto;
import edu.suda.xsap.service.EmployeeService;
import edu.suda.xsapadminutils.common.Result;
import edu.suda.xsapadminvo.EmployeeVO;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;

@RestController
@RequestMapping("/employee")
public class EmployeeController {

    @Autowired
    private EmployeeService employeeService;

    @PostMapping("/save")
    public Result save(@RequestBody EmployeeVO employeeVO) {
        System.out.println(employeeVO);
        return employeeService.save(employeeVO);
    }

    @GetMapping("/list")
    public List<EmployeeDto> findAll() {
        return employeeService.findAll();
    }

    @PostMapping("/delete")
    public Result delete(@RequestBody EmployeeVO employeeVO) {
        return employeeService.delete(employeeVO);
    }

    @PostMapping("/update")
    public Result update(@RequestBody EmployeeVO employeeVO) {
        return employeeService.update(employeeVO);
    }

}
